package com.sn.author.redis;

/**
 * @Author xiaom
 * @Date 2020/9/21 19:00
 * @Version 1.0.0
 * @Description <>
 **/
public class RedisKeyBuild {

    private static final String PREFIX = "api";

    private static final String CACHE_PREFIX = ":";

    public static final Integer _TIME_SECOND_ONE = 1;

    public static final Integer _TIME_MINUTE_ONE = _TIME_SECOND_ONE * 60;

    public static final Integer _TIME_HOUR_ONE = _TIME_MINUTE_ONE * 60;

    private static String buildKey(Object str1, String... array) {
        StringBuilder stringBuffer = new StringBuilder(PREFIX);
        stringBuffer.append(CACHE_PREFIX).append(str1);
        for (String obj : array) {
            stringBuffer.append(CACHE_PREFIX).append(obj);
        }
        return stringBuffer.toString();
    }

    /**
     * 任务队列key
     */
    public static String buildTaskQueueKey(String...keys){
        return buildKey(RedisConst._TASK_QUEUE, keys);
    }

    /**
     * 任务进度缓存key
     */
    public static String buildTaskProcessKey(String...keys){
        return buildKey(RedisConst._TASK_PROCESS_KEY,  keys);
    }
}
